<meta charset="UTF-8">
<table id="t_book"></table>
<script type="text/javascript">
$(function(){
	$("#t_book").datagrid({
		idField:'id',
		title: '学生列表',
		width: '100%',
		fitColumns: true,
		striped: true,
		loadMsg: '数据正在加载...',
		//rownumbers: true,
		url: 'books/listBooks',
		pagination: true,
		pageSize:3,
		pageList: [ 3, 20, 25, 50],
		columns:[
			[
				{field : 'id',title : '图片',align: 'center', width : 200,
					formatter:function(value){
			     		return '<img  src="books/download?id=' + value +'" style="width:85px;height:130px;">';
			}
		},
				/* {field: 'id',title: '唯一标识',width: 50,align: 'center'},  */
				{field:'byid',title:'编号',width: 100,align: 'center'},
				{field:'title',title:'书名',width: 100,align: 'center'},
				{field:'suthor',title:'作者',width: 100,align: 'center'},
				{field:'number',title:'数量',width: 100,align: 'center'}
		]
			],
		toolbar:[{
			text:'上传图书',
			iconCls:'icon-add',
			handler:function(){
				$('#mydialog').dialog({
					title: '上传图书',
					modal:true		
				});
				$('#myform input').val("");
				$('#mydialog').dialog('open');
			}
		}]
		
	});
	$('#btn1').click(function(){
		if($('#myform').form('validate')){
			/* $.ajax({
				type:'post',
				url:'books/save',
				cache:false,
				data:$('#myform').serialize(),
				success:function(data){
					$('#mydialog').dialog('close');
					$('#t_student').datagrid('reload');
					$.messager.show({
						title:'提示信息',
						msg:'操作成功！'
					});
				}
			}); */
			window.location="books/save";
		}else{
			$.messager.show({
				title:'提示信息',
				msg:'验证不通过，不能保存！'
			});
		}
	});
	$("#btn2").click(function(){
		$("#mydialog").dialog('close');
	});
});

</script>
<div id="mydialog"  class="easyui-dialog" closed=true >
<form id="" action="books/save" method="post" enctype="multipart/form-data">
	<p>上传图片：<input type="file" name="file"></p>
	<p>编号：<input type="text" name="byid"></p>
	<p>书名：<input type="text" name="title"></p>
	<p>作者：<input type="text" name="suthor"></p>
	<p>数量：<input type="text" name="number"></p>
	<p>
	<button type="submit">上传</button>
		<!-- <a id="btn1" class="easyui-linkbutton" iconCls="icon-save">确定</a>
		<a id="btn2" class="easyui-linkbutton" iconCls="icon-cancel">关闭</a> -->
	</p>
</form>
</div>